package leetcode;

import java.util.HashMap;

public class Test0003 {
    public static void run(){
        String s="fabcdef";

        int maxLength=0;

        int start=0,end=0;
        HashMap<Character,Integer> dic=new HashMap<Character, Integer>();
        char[]  chars= s.toCharArray();

        while (end<=s.length()-1){
            if(dic.containsKey(chars[end])){
                if(maxLength<end-start) {
                    maxLength = end - start;
                }
                dic.remove(chars[start]);
                start++;
            }
            else {
                dic.put(chars[end],0);
                end++;
            }
        }
        if(maxLength<end-start) {
            maxLength = end - start;
        }

        System.out.println(maxLength);
    }
}
